home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Environments / Clean 1.2.4 / IOInterface / deltaIOSystem.dcl < prev    next >
Encoding:
Modula Definition  |  1997-04-23  |  14.6 KB  |  345 lines  |  [TEXT/3PRM]

  1. definition module deltaIOSystem;
  2.  
  3. //    Version 0.8 to 1.0
  4.  
  5. //    Module deltaIOSystem specifies the IOSystems and Devices
  6. //    that can be used in Concurrent Clean Event I/O
  7.  
  8. from StdString import String;
  9. from deltaPicture import Picture, Rectangle, DrawFunction, Point;
  10.  
  11. ::    IOSystem     *s *io    :==    [DeviceSystem s io];
  12. ::    DeviceSystem *s *io    =    TimerSystem     [TimerDef    s io]
  13.                         |    MenuSystem     [MenuDef     s io]
  14.                         |    WindowSystem [WindowDef    s io]
  15.                         |    DialogSystem [DialogDef    s io];
  16.  
  17.  
  18. /*    The timer device:
  19.     The Timer responds only to timer events. A timer event occurs as
  20.     soon as a certain TimerInterval (a number in terms of 1/TicksPerSecond
  21.     seconds (see deltaTimer.dcl)) has expired since the last time it was
  22.     `sampled'. The timer event causes the programmer defined TimerFunction
  23.     to be evaluated. The TimerState argument of the TimerFunction indicates
  24.     how many times the TimerInterval has expired since the last timer
  25.     event. The timer device can initially be Able or Unable (SelectState).
  26.  
  27. ::    TimerDef *s *io
  28.     =    Timer TimerId SelectState TimerInterval (TimerFunction s io);
  29. ::    TimerId                            -> Int;
  30. ::    TimerInterval                    -> Int;
  31. ::    TimerFunction UNQ s UNQ io    -> => TimerState (=> s (=> io (s, io)));
  32. ::    TimerState                        -> Int;
  33.  
  34.  
  35. <<    The menu device may consist of several PullDownMenus. The PullDownMenus
  36.     are logically grouped into a menu bar, in the same order as they are
  37.     specified. PullDownMenus are selected by pressing the mousebutton on
  38.     their MenuTitle in the MenuBar. Menus contain MenuElements. The
  39.     MenuFunction of an element is executed when the element is selected. >>
  40.  
  41. ::    MenuDef UNQ s UNQ io
  42.         -> PullDownMenu MenuId MenuTitle SelectState [MenuElement s io];
  43. ::    MenuElement UNQ s UNQ io
  44.         -> MenuItem            MenuItemId ItemTitle KeyShortcut
  45.                                 SelectState (MenuFunction s io)
  46.         -> CheckMenuItem  MenuItemId ItemTitle KeyShortcut
  47.                                 SelectState MarkState (MenuFunction s io)
  48.         -> SubMenuItem        MenuId ItemTitle SelectState [MenuElement  s io]
  49.         -> MenuItemGroup    MenuItemGroupId [MenuElement  s io]
  50.         -> MenuRadioItems    MenuItemId [RadioElement s io]
  51.         -> MenuSeparator;
  52. ::    RadioElement UNQ s UNQ io
  53.         -> MenuRadioItem MenuItemId ItemTitle KeyShortcut
  54.                                 SelectState (MenuFunction s io);
  55. ::    MenuFunction UNQ s UNQ io -> => s (=> io (s, io));
  56. ::    MenuId                  -> INT;
  57. ::    MenuItemId              -> INT;
  58. ::    MenuItemGroupId    -> INT;
  59. ::    KeyShortcut            -> Key KeyCode | NoKey;
  60.  
  61.  
  62. <<    The window device may consist of several ScrollWindows or FixedWindows.
  63.     A ScrollWindow is defined by the following arguments:
  64.     - WindowId             : the number by which the programmer refers to the window.
  65.     - WindowPos             : the position of the upper-left corner of the window.
  66.     - WindowTitle         : the title of the window.
  67.     - WindowColourType : NormalColour allows only 8 colours (see deltaPicture)
  68.                                  and FullColour allows all RGB colours. Don't use
  69.                              FullColour windows on the Macintosh Plus.
  70.     - ScrollBarDefs     : the horizontal and vertical scrollbars (in that order).
  71.     - PictureDomain     : the range of the drawing operations in the window.
  72.     - MinimumWindowSize: the smallest dimensions of the (contents of a) window.
  73.     - InitialWindowSize: the initial dimensions of the (contents of a) window.
  74.     - UpdateFunction     : the function to redraw parts (UpdateArea) of the window.
  75.     - An attribute list that may contain the following window attributes:
  76.         - Activate    : the way to respond to activation of the window.
  77.         - Deactivate: the way to respond to deactivation of the window.
  78.         - GoAway        : the way to respond to a click in the go-away area.
  79.         - Keyboard  : the way the window responds to keyboard input.
  80.         - Mouse     : the way the window responds to mouse input.
  81.         - Cursor    : the shape of the mouse pointer inside the window.
  82.         - StandByWindow: When this attribute is present the window will be a so-called
  83.                          stand-by window: The mouse event related to the activation
  84.                          of the window will be handled also.
  85.     A FixedWindow has a fixed size, which is defined by its PictureDomain.
  86.     Therefore it has no scroll bars and no size parameters. When the PictureDomain
  87.     of a FixedWindow becomes greater that on of the screen's dimensions it
  88.     becomes a ScrollWindow. >>
  89.  
  90. ::    WindowDef UNQ s UNQ io
  91.     -> ScrollWindow WindowId WindowPos WindowTitle
  92.                          ScrollBarDef ScrollBarDef
  93.                          PictureDomain MinimumWindowSize InitialWindowSize
  94.                          (UpdateFunction s) [WindowAttribute s io]
  95.     -> FixedWindow WindowId WindowPos WindowTitle
  96.                         PictureDomain (UpdateFunction s) [WindowAttribute s io];
  97.  
  98. ::    WindowId                    -> INT;
  99. ::    WindowPos                -> (!INT, !INT);
  100. ::    WindowTitle                -> STRING;
  101. ::    ScrollBarDef            -> ScrollBar ThumbValue ScrollValue;
  102. ::    ThumbValue                -> Thumb  INT;
  103. ::    ScrollValue                -> Scroll INT;
  104. ::    MinimumWindowSize        -> (!INT, !INT);
  105. ::    InitialWindowSize        -> (!INT, !INT);
  106. ::    UpdateArea                -> [Rectangle];
  107. ::    UpdateFunction UNQ s    -> => UpdateArea (=> s (s, [DrawFunction]));
  108.  
  109. ::    WindowAttribute UNQ s UNQ io
  110.         ->    Activate        (WindowFunction s io)
  111.         ->    Deactivate    (WindowFunction s io)
  112.         ->    GoAway        (WindowFunction s io)
  113.         ->    Mouse            SelectState (MouseFunction s io)
  114.         ->    Keyboard        SelectState (KeyboardFunction s io)
  115.         ->    Cursor        CursorShape
  116.         ->    StandByWindow;
  117.  
  118. ::    WindowFunction      UNQ s UNQ io -> => s (=> io (s, io));        
  119. ::    MouseFunction      UNQ s UNQ io -> => MouseState      (=> s (=> io (s, io)));
  120. ::    KeyboardFunction UNQ s UNQ io -> => KeyboardState (=> s (=> io (s, io)));
  121.  
  122. ::    KeyboardState    -> (!KeyCode, !KeyState, !Modifiers);
  123. ::    KeyCode            -> CHAR;
  124. ::    KeyState            -> KeyUp | KeyDown | KeyStillDown;
  125.  
  126. ::    MouseState        -> (!MousePosition, !ButtonState, !Modifiers);
  127. ::    MousePosition    -> (!INT, !INT);
  128. ::    ButtonState        -> ButtonUp | ButtonDown | ButtonDoubleDown |
  129.                             ButtonTripleDown | ButtonStillDown;
  130.  
  131. ::    CursorShape    ->    StandardCursor    | BusyCursor     | IBeamCursor |
  132.                   CrossCursor    | FatCrossCursor | ArrowCursor | HiddenCursor;
  133.  
  134.  
  135. <<    The dialog device: Modal dialogs given in the initial dialog device are
  136.     ignored. Use the Open(Modal)Dialog function (deltaDialog.icl) to open dialogs
  137.     during the interaction. PropertyDialogs are special modeless dialogs with
  138.     two predefined buttons: the Set and the Reset button. A CommandDialog can
  139.     be modal as well as modeless.
  140.     A PropertyDialog is defined by the following attributes:
  141.     - DialogId: a number by which the programmer can refer to the dialog.
  142.     - DialogTitle: The title of the dialog (ignored for modal dialogs).
  143.     - A list of attributes that may contain the following dialog attributes:
  144.       - DialogPos     : The position of the dialog on the screen.
  145.       - DialogSize     : The size of the dialog.
  146.       - DialogMargin: The horizontal and vertical margins between the borders
  147.                       of the dialog and the items.
  148.       - ItemSpace     : The horizontal and vertical space between the items of
  149.                       the dialog.
  150.       - StandByDialog: When this attribute is present the dialog will be a so-called
  151.                        stand-by dialog: it will also react to the MouseDown related
  152.                        to activation of the dialog.
  153.       When none of these attributes is specified the dialog is centered on
  154.       the screen, a size is chosen such that all items fit in the dialog and
  155.       safe default margins and item spaces are chosen. The first Measure always
  156.       is the horizontal attribute value, the second is always the vertical
  157.       attribute value.
  158.     - SetFunction/ResetFunction: The button function for the set/reset button.
  159.     - A list of DialogItems        : Other items such as CheckBoxes, Control's etc..
  160.     A CommandDialog also has an id, a title, a position, a size and a list of
  161.     DialogItems. Furthermore it has the following attribute:
  162.     - DialogItemId: The item id of the default button.
  163.     In the AboutDialog information about the application (version, authors etc.)
  164.     can be presented. The first AboutDialog encountered in the initial
  165.     DialogDevice becomes the AboutDialog of the application. Attempts to open
  166.     AboutDialogs with OpenDialog are ignored. The AboutDialog may contain a button
  167.     which should provide a help facility. The AboutDialog will be accessible by
  168.     the user during the interaction in a system-dependent way. >>
  169.  
  170. ::    DialogDef UNQ s UNQ io
  171.     -> PropertyDialog DialogId DialogTitle [DialogAttribute] (SetFunction s io)
  172.                       (ResetFunction s io) [DialogItem s io]
  173.     -> CommandDialog  DialogId DialogTitle [DialogAttribute]
  174.                       DialogItemId [DialogItem s io]
  175.     -> AboutDialog    ApplicationName PictureDomain [DrawFunction] (AboutHelpDef s io);
  176.  
  177. ::    DialogId        -> INT;
  178. ::    DialogTitle    -> STRING;
  179. ::    DialogAttribute
  180.     -> DialogPos    Measure Measure
  181.     -> DialogSize   Measure Measure
  182.     -> DialogMargin Measure Measure
  183.     -> ItemSpace    Measure Measure
  184.     -> StandByDialog;
  185. ::    Measure     -> MM REAL | Inch REAL | Pixel INT;
  186.  
  187. ::    ApplicationName -> STRING;
  188. ::    AboutHelpDef UNQ s UNQ io
  189.     -> AboutHelp ItemTitle (AboutHelpFunction s io)
  190.     -> NoHelp;
  191. ::    AboutHelpFunction UNQ s UNQ io -> => s (=> io (s,io));
  192.  
  193. <<    A DialogItem can be a final button (DialogButton), a final button with a
  194.     user-defined look (DialogIconButton), an unchangable piece of text
  195.     (StaticText), a changeable piece of text (DynamicText), an editable text
  196.     field (EditText), a group of RadioButtons, a group of CheckBoxes, or a
  197.     user-defined Control. The ItemPos specifies the position of the item
  198.     relative to the other items. When the ItemPos is DefPos the item is placed
  199.     beneath all other items, left-aligned. >>
  200.  
  201. ::    DialogItem UNQ s UNQ io
  202.     -> DialogButton DialogItemId ItemPos ItemTitle SelectState
  203.                      (ButtonFunction s io)
  204.     -> DialogIconButton DialogItemId ItemPos PictureDomain IconLook
  205.                         SelectState (ButtonFunction s io)
  206.     -> StaticText DialogItemId ItemPos STRING
  207.     ->    DynamicText DialogItemId ItemPos TextWidth STRING
  208.     -> EditText DialogItemId ItemPos TextWidth NrEditLines STRING
  209.     -> DialogPopUp  DialogItemId ItemPos SelectState DialogItemId
  210.                     [RadioItemDef s io]
  211.     -> RadioButtons DialogItemId ItemPos RowsOrColumns DialogItemId
  212.                     [RadioItemDef s io]
  213.     -> CheckBoxes DialogItemId ItemPos RowsOrColumns [CheckBoxDef s io]
  214.     -> Control DialogItemId ItemPos PictureDomain SelectState ControlState
  215.                 ControlLook ControlFeel (DialogFunction s io);
  216.  
  217. ::    DialogItemId    -> INT;
  218. ::    ItemPos            -> Left | Center | Right | RightTo DialogItemId |
  219.                             Below DialogItemId | XOffset DialogItemId Measure |
  220.                            YOffset DialogItemId Measure | XY Measure Measure |
  221.                            ItemBox INT INT INT INT;
  222. ::    IconLook            -> => SelectState [DrawFunction];
  223. ::    TextWidth        -> Measure;
  224. ::    NrEditLines        -> INT;
  225. ::    RowsOrColumns    -> Rows INT | Columns INT;
  226.  
  227. ::    RadioItemDef UNQ s UNQ io
  228.     -> RadioItem DialogItemId ItemTitle SelectState (DialogFunction s io);
  229. ::    CheckBoxDef UNQ s UNQ io
  230.     -> CheckBox DialogItemId ItemTitle SelectState MarkState
  231.                 (DialogFunction s io);
  232.  
  233. <<    Attributes of a user-defined control: The ControlState can be a boolean, an
  234.     integer, a real, a string or a pair or list of one of these basic types.
  235.     The look of the Control is defined by the list of drawfunctions returned by
  236.     the ControlLook function. The ControlFeel defines the way to respond to mouse
  237.     clicks in the Control's picture domain. >>
  238.  
  239. ::    ControlState    -> BoolCS BOOL | IntCS INT | RealCS REAL | StringCS STRING |
  240.                            PairCS ControlState ControlState | ListCS [ControlState];
  241. ::    ControlLook     -> => SelectState (=> ControlState [DrawFunction]);
  242. ::    ControlFeel     -> => MouseState  (=> ControlState
  243.                                       (ControlState,[DrawFunction]));
  244.  
  245. <<    Types of the several dialog item functions. >>
  246.  
  247. ::    SetFunction    UNQ s UNQ io -> ButtonFunction s io;
  248. ::    ResetFunction  UNQ s UNQ io -> ButtonFunction s io;
  249. ::    DialogFunction UNQ s UNQ io
  250.     -> => DialogInfo (=> (DialogState s io) (DialogState s io));
  251. ::    ButtonFunction  UNQ s UNQ io
  252.     -> => DialogInfo (=> s (=> io (s,io)));
  253.  
  254. <<    A notice is a simple, modal dialog containing only text and final buttons.
  255.     It can be used to inform the user about unusual or dangerous situations.
  256.     Notices can be opened with the OpenNotice function (deltaDialog) A notice
  257.     is defined by the following attributes:
  258.     - A list of strings: Each string is a line of the message of the notice.
  259.     - A NoticeButtonDef: The default button of the notice.
  260.     - A list of NoticeButtonDefs: The other buttons of the notice. >>
  261.  
  262. ::    NoticeDef         -> Notice [STRING] NoticeButtonDef [NoticeButtonDef];
  263. ::    NoticeButtonDef -> NoticeButton NoticeButtonId ItemTitle;
  264. ::    NoticeButtonId     -> INT;
  265.  
  266.  
  267. <<    For each modifier (Shift,Option,Command,Control) a boolean in Modifiers
  268.     indicates whether it was pressed (TRUE) or not (FALSE). On systems that
  269.     have no Command key both the third and the fourth boolean become TRUE when
  270.     Control is pressed. >>
  271.  
  272. ::    Modifiers     -> (BOOL,BOOL,BOOL,BOOL);
  273. ::    ItemTitle    -> STRING;
  274. ::    SelectState    -> Able | Unable;
  275. ::    MarkState    -> Mark | NoMark;
  276. */
  277.  
  278. from timerDef import
  279.     TimerDef, Timer, TimerId, TimerInterval, TimerFunction, TimerState;
  280. from menuDef import
  281.     MenuDef,
  282.         PullDownMenu, MenuId, MenuTitle, MenuElement,
  283.         MenuItem, MenuItemId, KeyShortcut, MenuFunction,
  284.         CheckMenuItem,
  285.         SubMenuItem,
  286.         MenuItemGroup, MenuItemGroupId,
  287.         MenuRadioItems, RadioElement,
  288.         MenuSeparator,
  289.         MenuRadioItem,
  290.         Key, NoKey;
  291. from windowDef import
  292.     WindowDef,
  293.         ScrollWindow, FixedWindow,
  294.             WindowId, WindowPos, WindowTitle, ScrollBarDef,
  295.             MinimumWindowSize, InitialWindowSize, UpdateFunction, WindowAttribute,
  296.         ScrollBar, ThumbValue, ScrollValue, Thumb, Scroll,
  297.         UpdateArea,
  298.         Activate, Deactivate, GoAway, WindowFunction,
  299.         Mouse, MouseFunction,
  300.         Keyboard, KeyboardFunction,
  301.         StandByWindow,
  302.         Cursor, CursorShape,
  303.             StandardCursor, BusyCursor, IBeamCursor,
  304.             CrossCursor, FatCrossCursor, ArrowCursor, HiddenCursor;
  305. from dialogDef import
  306.     DialogInfo,
  307.     DialogState,
  308.     DialogDef,
  309.         PropertyDialog, DialogId, DialogTitle,
  310.         DialogAttribute,
  311.             DialogSize, DialogPos, DialogMargin, ItemSpace, StandByDialog,
  312.         Measure, MM, Inch, Pixel,
  313.         SetFunction, ResetFunction,
  314.         CommandDialog,
  315.         AboutDialog, ApplicationName,
  316.             AboutHelpDef, AboutHelp, NoHelp, AboutHelpFunction,
  317.         DialogItemId,
  318.         DialogItem, DialogButton, DialogPopUp,
  319.         ItemPos,
  320.             Left, Center, Right, RightTo, Below, XOffset, YOffset, XY, ItemBox,
  321.         ButtonFunction,
  322.         DialogIconButton, IconLook,
  323.         StaticText, DynamicText,
  324.         EditText, TextWidth, NrEditLines,
  325.         RadioButtons,
  326.         RowsOrColumns, Rows, Columns,
  327.         RadioItemDef, RadioItem, DialogFunction, 
  328.         CheckBoxes,
  329.         CheckBoxDef, CheckBox,
  330.         Control, ControlLook, ControlFeel, ControlState,
  331.             BoolCS, IntCS, RealCS, StringCS, PairCS, ListCS,
  332.     NoticeDef,
  333.         Notice,
  334.         NoticeButtonId, NoticeButtonDef, NoticeButton;
  335. from commonDef import
  336.     ItemTitle,
  337.     SelectState, Able, Unable,
  338.     MarkState, Mark, NoMark,
  339.     KeyboardState, KeyCode, KeyState,
  340.         KeyUp, KeyDown, KeyStillDown,
  341.     MouseState, MousePosition, ButtonState,
  342.         ButtonUp, ButtonDown, ButtonDoubleDown, ButtonTripleDown, ButtonStillDown,
  343.     Modifiers,
  344.     PictureDomain;
  345.